Lessthan and TEXif

Finally, we would like to be able to use TEX's built-in booleans as well as our own. For example, we would like a predicate Lessthan such that:

#math116#
Lessthan~i~j = #tex2html_wrap_indisplay2333##tex2html_wrap_indisplay2334#  

The Error condition happens if we try applying Lessthan to something that isn't a number --- #math117#Lessthan~True~False is Error36 1. This is fine as a mathematical definition, but how will we implement it? If we assume we have a macro 22, which converts TEX if-statements into booleans, we could just define:
 
So the question is just how to define 23. Unfortunately, the ``obvious'' code does not work:
verbatim69#
For example, 24 doesn't expand out to 25. Instead, it expands as:
verbatim70#
Another common TEXnique is to use a macro 26 to be the expansion text:
verbatim71#
However, this uses TEX's stomach to do the 27, and we are trying to do this using only the mouth. One (slightly tricky) solution is to use pattern-matching to gobble up the offending 28 and/or 29.
 
So if the TEX if-statement is true, 30 gobbles up the false-text, otherwise 31 gobbles up the true-text. For example,
verbatim72#
Phew. And so we have booleans.